package com.hzl.lease.common.exception;

import com.hzl.lease.common.result.Result;
import com.hzl.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {
    //异常处理方法

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exception(Exception e){
        System.out.println("前端异常信息提示");
        e.printStackTrace();
        return Result.fail();
       // return Result.fail(ResultCodeEnum.UPLOAD_FAIL);
    }


    @ExceptionHandler(LeaseException.class)
    @ResponseBody
    public Result leaseException(LeaseException e){
        System.out.println("异常信息提示!");
        e.printStackTrace();
        return Result.fail(e.getCode(),e.getMessage());
        // return Result.fail(ResultCodeEnum.UPLOAD_FAIL);
    }


}

